﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WatiN.Core;
using NUnit.Framework;
using System.Threading;

namespace consoletest
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            #region China Insurance
            /*
            using (var browser = new IE("http://www.sg.cntaiping.com/chinainsB2B/Login.aspx"))
            {
                browser.TextField(Find.ByName("txtUserID")).SetText("BR0001A-01");
                browser.TextField(Find.ByName("txtPassword")).SetText("ACCLAIM02");
                browser.Button(Find.ByName("cmdLogin")).Click();

                // Frame frame = browser.Frame(Find.ByName("mainFrame"));
                // frame.Link(Find.ByName("B2B Services")).Click();         // frames have this COM problem
                browser.GoTo("http://www.sg.cntaiping.com/chinainsB2B/Motor/Private/PteCarQuote.aspx");
                browser.SelectList(Find.ByName("cboCoverage")).Select("Comprehensive");
                browser.TextField(Find.ByName("txtName2")).SetText("Shawn Lin");
                browser.TextField(Find.ByName("txtDOB")).SetText("07-08-1984");
                browser.TextField(Find.ByName("txtPassDate")).SetText("07-08-2003");
                browser.RadioButton(Find.ById("M")).Click();
                browser.RadioButton(Find.ById("occNo")).Click();
                browser.TextField(Find.ByName("MOTOR_PROCCUPATION")).SetText("Professional gamer");
                browser.TextField(Find.ByName("txtRegNo")).SetText("SKD1337");
                browser.TextField(Find.ByName("txtRegYr")).SetText("2010");
                browser.SelectList(Find.ByName("C_MOTOR_PRVEHMAKE")).Select("Toyota");
                using (var popup = IE.AttachTo<IE>(Find.ByUrl("http://www.sg.cntaiping.com/chinainsB2B/Motor/Common/QueryModelDetails.aspx?TYPE=P&VEHMAKE=Toyota")))
                {
                    popup.SelectList(Find.ByName("cboVehModel")).Select("Toyota Corolla 1.5 XLI {Saloon 1497cc}");   // TY07
                }
                browser.TextField(Find.ByName("C_MOTOR_PRNCD")).SetText("40");  // 30%

                browser.TextField(Find.ByName("Lol")).SetText("Hi");
            }
            */
            #endregion
            
            #region AXA Partners
            /*
            using (var browser = new IE("https://www.eservices.axa.com.sg/insurance/gs/servlet/com.ebao.gs.pol.nb.action.CreateQuotationAction"))
            {
                browser.TextField(Find.ByName("username")).SetText("SAGT00657");
                browser.TextField(Find.ByName("password")).SetText("67431220Di");
                browser.Button(Find.ByName("Submit")).Click();
                browser.GoTo("https://www.eservices.axa.com.sg/insurance/gs/servlet/com.ebao.gs.pol.nb.action.CreateQuotationAction");
                browser.Button(Find.ByValue("Continue")).Click();
                browser.TextField(Find.ByName("surName")).SetText("SamShawn");
                browser.TextField(Find.ByName("handphone")).SetText("82984790");
                browser.SelectList(Find.ByName("make")).Select("TOYOTA");
                browser.TextField(Find.ByName("yearMake")).SetText("2010");
                browser.TextField(Find.ByName("driverName")).SetText("Lin");
                browser.TextField(Find.ByName("driverExp")).SetText("8");
                browser.SelectList(Find.ByName("maritalStatusCode")).SetText("S");
                browser.TextField(Find.ByName("claimCount")).SetText("0");
                browser.SelectList(Find.ByName("driverOccupation")).SetText("132");
                browser.SelectList(Find.ByName("nameOrder")).SetText("1");
                browser.TextField(Find.ByName("dateOfBirth")).SetText("07/08/1984");
                browser.SelectList(Find.ByName("genderCode")).SetText("M");
                browser.TextField(Find.ByName("claimAmount")).SetText("0");
                browser.SelectList(Find.ByName("countryCode")).SetText("SIN");
                // browser.Button(Find.ByValue("Additional Driver")).Click();
                browser.SelectList(Find.ByName("ncdEnt")).SetText("3"); // 30%
                // browser.TextField(Find.ByName("effDate")).SetText("23/09/2011");
                // browser.TextField(Find.ByName("expDate")).SetText("22/09/2012");
                browser.SelectList(Find.ByName("ctId")).SetText("18324_");  // comprehensive
                browser.Button(Find.ByName("addButton")).Click();
                browser.Button(Find.ByValue("Calculate")).Click();

                browser.TextField(Find.ByName("Lol")).SetText("hi");
            }
            */
            #endregion

            #region Chartis Insurance
            /*
            using (var browser = new IE("https://www-406.chartisinsurance.com.sg/portal/wam/login.jsf"))
            {
                501873ssis / Pass05words
            }
            */
            #endregion

            #region Tokio Marine Insurance
            using (var browser = new IE("https://connect.tokiomarine.com.sg/Intermediaries/Security/IntermediaryLogin.aspx"))
            {
                browser.TextField(Find.ByName("ctl00$eTranContentPlaceHolder01$Login$UserIDText")).SetText("1407DDA");    // User ID
                browser.TextField(Find.ByName("ctl00$eTranContentPlaceHolder01$Login$PasswordText")).SetText("samshawn"); // Password
                browser.Button(Find.ByValue("Login")).Click();
                browser.GoTo("https://connect.tokiomarine.com.sg/eTran/eMotorVehicle/MotorMain0911.aspx");
                browser.SelectList(Find.ByName("ctl00$eTranContentPlaceHolder02$TX020001")).SetText("CO");                // Coverage Type
                browser.TextField(Find.ByName("ctl00$eTranContentPlaceHolder02$TX020003")).SetText("23/09/2011");         // Start Date for Policy
                browser.TextField(Find.ByName("ctl00$eTranContentPlaceHolder02$TX020004")).SetText("22/09/2012");         // End Date for Policy
                browser.SelectList(Find.ByName("ctl00$eTranContentPlaceHolder02$TX020006")).Select("1");                  // No. Of Named Driver(s)
                browser.SelectList(Find.ByName("ctl00$eTranContentPlaceHolder02$TX020101")).Select("Individual");         // Type Of Applicant
                browser.SelectList(Find.ByName("ctl00$eTranContentPlaceHolder02$TX020102")).SetText("MR");                // Salutation
                browser.TextField(Find.ByName("ctl00$eTranContentPlaceHolder02$TX020103")).SetText("SHAWN LIN JINGJUE");  // Name as in NRIC
                browser.TextField(Find.ByName("ctl00$eTranContentPlaceHolder02$TX020105")).SetText("S9227956A");          // NRIC/FIN Number
                browser.SelectList(Find.ByName("ctl00$eTranContentPlaceHolder02$TX020109")).SetText("M");                 // Gender
                browser.SelectList(Find.ByName("ctl00$eTranContentPlaceHolder02$TX020106")).SetText("SGP");               // Nationality
                browser.TextField(Find.ByName("ctl00$eTranContentPlaceHolder02$TX020110")).SetText("82984790");           // Mobile No.
                browser.TextField(Find.ByName("ctl00$eTranContentPlaceHolder02$TX020120")).SetText("83");                 // Blk/Street No.


                browser.TextField(Find.ByName("Lol")).SetText("hi");
            }
            #endregion

            #region Tenet Insurance
            using (var browser = new IE("http://www.tenetinsurance.com/pib/privatevehiclequote/index.asp"))
            {
                browser.TextField(Find.ByName("str_clientname")).SetText("Jacob");
                browser.SelectList(Find.ByName("str_salutation")).SetText("Mr.");
                browser.SelectList(Find.ByName("str_occupation")).SetText("Accountant");
                browser.SelectList(Find.ByName("str_dateofbirth_day")).SetText("7");
                browser.SelectList(Find.ByName("str_dateofbirth_month")).SetText("8");
                browser.SelectList(Find.ByName("str_dateofbirth_year")).SetText("1984");
                browser.SelectList(Find.ByName("str_nationality")).SetText("Singaporean");
                browser.SelectList(Find.ByName("int_drivingexperience")).SetText("8");
                browser.SelectList(Find.ByName("str_claimsinlast2years")).SetText("0");
                browser.SelectList(Find.ByName("str_totalvalueofclaim")).SetText("0");
                browser.SelectList(Find.ByName("str_yearofmanufacture")).SetText("2009");
                browser.SelectList(Find.ByName("str_yearofregistration")).SetText("2010");
                browser.SelectList(Find.ByName("str_vehiclemake")).Select("TOYOTA");
                browser.SelectList(Find.ByName("str_vehiclemodel")).Select("TOYOTA COROLLA 1.3 DX");
                browser.SelectList(Find.ByName("str_vehicleseatingcapacity")).SetText("05");
                browser.SelectList(Find.ByName("str_COEExpirydate_day")).SetText("10");
                browser.SelectList(Find.ByName("str_COEExpirydate_month")).SetText("10");
                browser.SelectList(Find.ByName("str_COEExpirydate_year")).SetText("2015");
                browser.SelectList(Find.ByName("str_demeritpoint")).SetText("0");
                //browser.SelectList(Find.ByName("str_OtherInsurancetypes1")).SetText("Select an Optional Extension");
                //browser.SelectList(Find.ByName("str_OtherInsurancetypes2")).SetText("Select an Optional Extension");
                //browser.SelectList(Find.ByName("str_OtherInsurancetypes3")).SetText("Select an Optional Extension");
                //browser.SelectList(Find.ByName("str_OtherInsurancetypes4")).SetText("Select an Optional Extension");
                browser.SelectList(Find.ByName("int_OFD")).SetText("0");
                browser.SelectList(Find.ByName("int_NCD")).SetText("30");
                browser.SelectList(Find.ByName("str_noofnameddrivers")).SetText("1");
                browser.RadioButton(Find.ByName("bit_isspousenameddriver")).SetValue("0");

                DateTime today = DateTime.Today;
                browser.SelectList(Find.ByName("str_periodfrom_day")).SetText(today.Day.ToString());
                browser.SelectList(Find.ByName("str_periodfrom_month")).SetText(today.Month.ToString());
                browser.SelectList(Find.ByName("str_periodfrom_year")).SetText(today.Year.ToString());
                browser.SelectList(Find.ByName("str_periodto_day")).SetText(DateTime.Today.AddYears(1).Day.ToString());
                browser.SelectList(Find.ByName("str_periodto_month")).SetText(DateTime.Today.AddYears(1).Month.ToString());
                browser.SelectList(Find.ByName("str_periodto_year")).SetText(DateTime.Today.AddYears(1).Year.ToString());

                browser.Image(Find.ByName("cmd_submit_pv_quotation")).Click();

                // browser.SelectList(Find.ByName("lol")).SetText("hi");
            }
            #endregion

            #region HSBC Insurance
            using (var browser = new IE("http://www.insurance.hsbc.com.sg/1/2/sghi/personal-insurance/protection/autosurance"))
            {
                browser.Image(Find.ByAlt("AutoSurance Take to the road with extra peace of mind")).Click();
                using (var popup = IE.AttachTo<IE>(Find.ByUrl("https://applications.insurance.hsbc.com.sg/MotorsuranceWeb/Quote/Premium1PAction.do")))
                {
                    popup.SelectList(Find.ByName("cover")).SetText("Classic");
                    popup.SelectList(Find.ByName("dateOfBirthDay")).SetText("7");
                    popup.SelectList(Find.ByName("dateOfBirthMonth")).SetText("8");
                    popup.TextField(Find.ByName("dateOfBirthYear")).SetText("1984");
                    popup.SelectList(Find.ByName("licenseObtainedDay")).SetText(Common.licDay);
                    popup.SelectList(Find.ByName("licenseObtainedMonth")).SetText(Common.licMonth);
                    popup.TextField(Find.ByName("licenseObtainedYear")).SetText(Common.licYear);
                    popup.SelectList(Find.ByName("noClaimDiscount")).SetText("30");
                    popup.SelectList(Find.ByName("usageCar")).SetText("CLASS 1A - INDOOR/OUTDOOR     ");
                    popup.SelectList(Find.ByName("makeCar")).SetText("TOYOTA                        ");
                    popup.TextField(Find.ByName("modelCar")).SetText("TOYOTA COROLLA 1.3 DX");
                    popup.SelectList(Find.ByName("bodyCar")).SetText("SALOON                        ");
                    popup.TextField(Find.ByName("capacityCar")).SetText("1290");
                    popup.TextField(Find.ByName("yearCarRegistered")).SetText("2010");
                    popup.Button(Find.ByName("submitButton")).Click();
                    popup.CheckBox(Find.ByName("businessUsage")).Click();
                    popup.Button(Find.ByValue(" Next ")).Click();

                    // popup.SelectList(Find.ByName("lol")).SetText("hi");
                }
            }
            #endregion

        }
    }
}
